{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b94d6307",
   "metadata": {},
   "source": [
    "### Import dependencies"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "5086f512",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-03-28T20:34:56.066612Z",
     "iopub.status.busy": "2023-03-28T20:34:56.066612Z",
     "iopub.status.idle": "2023-03-28T20:34:56.334168Z",
     "shell.execute_reply": "2023-03-28T20:34:56.334168Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time: 219 ms (started: 2023-06-06 01:09:33 +02:00)\n"
     ]
    }
   ],
   "source": [
    "%load_ext autotime\n",
    "\n",
    "from IPython.display import display_html\n",
    "from PIL import Image as PILImage\n",
    "from openpyxl import load_workbook\n",
    "from io import BytesIO\n",
    "import cv2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "90eaf8af",
   "metadata": {},
   "source": [
    "### Documents\n",
    "\n",
    "Documents can be either an image or a PDF file. Check README for supported formats."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2594279d",
   "metadata": {},
   "source": [
    "#### Image"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "6e7b95fa",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-03-28T20:34:56.334168Z",
     "iopub.status.busy": "2023-03-28T20:34:56.334168Z",
     "iopub.status.idle": "2023-03-28T20:34:59.191605Z",
     "shell.execute_reply": "2023-03-28T20:34:59.191605Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time: 4.09 s (started: 2023-06-06 01:09:35 +02:00)\n"
     ]
    }
   ],
   "source": [
    "from img2table.document import Image\n",
    "\n",
    "img_path = \"data/tables.png\"\n",
    "\n",
    "# Definition of image from path\n",
    "img_from_path = Image(src=img_path)\n",
    "\n",
    "# Definition of image from bytes\n",
    "with open(img_path, 'rb') as f:\n",
    "    img_bytes = f.read()\n",
    "img_from_bytes = Image(src=img_bytes)\n",
    "\n",
    "# Definition of image from file-like object\n",
    "img_from_file_like = Image(src=BytesIO(img_bytes))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "083c21e4",
   "metadata": {},
   "source": [
    "#### PDF"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "46a763f3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-03-28T20:34:59.191605Z",
     "iopub.status.busy": "2023-03-28T20:34:59.191605Z",
     "iopub.status.idle": "2023-03-28T20:34:59.207085Z",
     "shell.execute_reply": "2023-03-28T20:34:59.207085Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time: 16 ms (started: 2023-06-06 01:09:42 +02:00)\n"
     ]
    }
   ],
   "source": [
    "from img2table.document import PDF\n",
    "\n",
    "pdf_path = \"data/tables.pdf\"\n",
    "\n",
    "# Definition of PDF from path\n",
    "# The optional pages argument enables the extraction of table on specific pages of the PDF\n",
    "pdf_from_path = PDF(src=pdf_path, pages=[0, 1])\n",
    "\n",
    "# Definition of PDF from bytes\n",
    "with open(pdf_path, 'rb') as f:\n",
    "    pdf_bytes = f.read()\n",
    "pdf_from_bytes = PDF(src=pdf_bytes)\n",
    "\n",
    "# Definition of PDF from file-like object\n",
    "pdf_from_file_like = PDF(src=BytesIO(pdf_bytes))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "42f85a7f",
   "metadata": {},
   "source": [
    "### OCR instances\n",
    "\n",
    "<code>img2table</code> provides supports for several OCR tools and services :\n",
    "  * Tesseract\n",
    "  * PaddleOCR\n",
    "  * EasyOCR\n",
    "  * Google Vision\n",
    "  * AWS Textract\n",
    "  * Azure Cognitive Services\n",
    "  \n",
    "For all OCRs except Tesseract, a specific installation is needed. Check README for relevant instructions."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "92778211",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-03-28T20:34:59.207085Z",
     "iopub.status.busy": "2023-03-28T20:34:59.207085Z",
     "iopub.status.idle": "2023-03-28T20:35:00.133689Z",
     "shell.execute_reply": "2023-03-28T20:35:00.133689Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time: 2.56 s (started: 2023-06-06 01:09:43 +02:00)\n"
     ]
    }
   ],
   "source": [
    "# Tesseract OCR\n",
    "from img2table.ocr import TesseractOCR\n",
    "\n",
    "tesseract_ocr = TesseractOCR(n_threads=1, lang=\"eng\")\n",
    "\n",
    "# PaddleOCR\n",
    "from img2table.ocr import PaddleOCR\n",
    "\n",
    "paddle_ocr = PaddleOCR(lang=\"en\")\n",
    "\n",
    "# EasyOCR\n",
    "from img2table.ocr import EasyOCR\n",
    "\n",
    "easyocr = EasyOCR(lang=[\"en\"])\n",
    "\n",
    "# Google Vision OCR\n",
    "from img2table.ocr import VisionOCR\n",
    "\n",
    "vision_ocr = VisionOCR(api_key=\"***\")\n",
    "\n",
    "# AWS Textract OCR\n",
    "from img2table.ocr import TextractOCR\n",
    "\n",
    "textract_ocr = TextractOCR(aws_access_key_id=\"***\",\n",
    "                           aws_secret_access_key=\"***\",\n",
    "                           aws_session_token=\"***\",\n",
    "                           region=\"eu-west-1\")\n",
    "\n",
    "# Azure Cognitive Services OCR\n",
    "from img2table.ocr import AzureOCR\n",
    "\n",
    "azure_ocr = AzureOCR(endpoint=\"abc.azure.com\",\n",
    "                           subscription_key=\"***\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "64139e2e",
   "metadata": {},
   "source": [
    "### Table identification\n",
    "\n",
    "For a document object (image or pdf), the <code>extract_tables</code> method can be called to perform table identification.<br>\n",
    "A list/dict of <code>ExtractedTable</code> objects is returned."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "bc97c4ba",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-03-28T20:35:00.133689Z",
     "iopub.status.busy": "2023-03-28T20:35:00.133689Z",
     "iopub.status.idle": "2023-03-28T20:35:00.212584Z",
     "shell.execute_reply": "2023-03-28T20:35:00.212584Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time: 78 ms (started: 2023-06-06 01:09:46 +02:00)\n"
     ]
    }
   ],
   "source": [
    "img = Image(src=\"data/tables.png\")\n",
    "\n",
    "# Extract tables\n",
    "extracted_tables = img.extract_tables()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "148f1e35",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-03-28T20:35:00.212584Z",
     "iopub.status.busy": "2023-03-28T20:35:00.212584Z",
     "iopub.status.idle": "2023-03-28T20:35:00.260258Z",
     "shell.execute_reply": "2023-03-28T20:35:00.260258Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABVUAAAGhCAIAAADutMP0AABI8UlEQVR4nO3deXxM9/7H8c8ZKvG7WnGrMlFuVGjUUoJeJNagTQmxxb4mWnvt1aoWaRWx9dpaS9EkdorScJFwS1LXdq2hpUKpJKoyljZRMd/fH6PTNJvINpOT1/Phj5wz53y/3zm+55vzztk0pZQAAAAAAABdM9i6AQAAAAAAIN+R/wEAAAAA0D/yPwAAAAAA+kf+BwAAAABA/8j/AAAAAADoH/kfAAAAAAD9I/8DAAAAAKB/5H8AAAAAAPSP/A8AAAAAgP6R/wEAAAAA0D/yPwAAAAAA+kf+BwAAAABA/8j/AAAAAADoH/kfAAAAAAD9I/8DAAAAAKB/5H8AAAAAAPSP/A8AAAAAgP6R/wEAAAAA0L/iBVeVphVcXQAAANmhlK1bgEKLg1vkEuMPClxBnf9nfAQAAHaIQxTkDD0HuUcvQoHj+n8AAAAAAPSvAK//t+AqFwAAYA8484Y8wcFthqz7F9snQ4w/sBHO/wMAAAAAoH/kfwAAAAAA9I/8DwAAAACA/pH/AQAAAADQP/I/AAAAAAD6R/4HAAAAAED/yP8AAAAAAOgf+R8AAAAAAP0j/wMAAAAAoH/kfwAAAAAA9I/8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AAAAAOgf+R8AAAAAAP0j/wMAAAAAoH/kfwAAAAAA9I/8DwAAAACA/pH/AQAAAADQP/I/AAAAAAD6R/4HAAAAAED/yP8AAAAAAOgf+R8AAAAAAP0j/wMAAAAAoH/kfwAAAAAA9I/8DwAAAACA/pH/AQAAAADQP/I/AAAAAAD6R/4HAAAAAED/yP8AAAAAAOgf+R8AAAAAAP0j/wMAAAAAoH/kfwAAAAAA9I/8DwAAAACA/pH/AQAAAADQP/I/AAAAAAD6R/4HAAAAAED/yP8AAAAAAOgf+R8AAAAAAP0j/wMAAAAAoH/kfwAAAAAA9I/8DwAAAACA/pH/AQAAAADQP/I/AAAAAAD6R/4HAAAAAED/yP8AAAAAAOgf+R8AAAAAAP0j/wMAAAAAoH/kfwAAAAAA9I/8DwAAAACA/pH/AQAAAADQP/I/AAAAAAD6R/4HAAAAAED/yP8AAAAAAOgf+R8AAAAAAP0j/wMAAAAAoH/kfwAAAAAA9I/8DwAAAACA/pH/AQAAAADQP/I/AAAAAAD69/8Bmd+622f7NwAAAABJRU5ErkJggg==",
      "text/plain": [
       "<PIL.Image.Image image mode=RGB size=1365x417>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time: 16 ms (started: 2023-06-06 01:09:46 +02:00)\n"
     ]
    }
   ],
   "source": [
    "# Display extracted tables\n",
    "table_img = cv2.imread(\"data/tables.png\")\n",
    "\n",
    "for table in extracted_tables:\n",
    "    for row in table.content.values():\n",
    "        for cell in row:\n",
    "            cv2.rectangle(table_img, (cell.bbox.x1, cell.bbox.y1), (cell.bbox.x2, cell.bbox.y2), (255, 0, 0), 2)\n",
    "            \n",
    "PILImage.fromarray(table_img)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "229e9a8e",
   "metadata": {},
   "source": [
    "### Table extraction\n",
    "\n",
    "If an ocr instance is provided to the <code>extract_table</code> method, cells content will be infered from the OCR result.<br>\n",
    "A <code>pd.DataFrame</code> representation of the extracted tables can be accessed via the <code>df</code> attribute."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ea97f8d0",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-03-28T20:35:00.260258Z",
     "iopub.status.busy": "2023-03-28T20:35:00.260258Z",
     "iopub.status.idle": "2023-03-28T20:35:00.918518Z",
     "shell.execute_reply": "2023-03-28T20:35:00.918518Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0: [ExtractedTable(title=Example of Data Table 1, bbox=(235, 249, 1442, 543),shape=(5, 4)),\n",
       "  ExtractedTable(title=Example of Data Table 2, bbox=(235, 671, 1451, 971),shape=(5, 4))],\n",
       " 1: [ExtractedTable(title=Example of Data Table 3, bbox=(236, 249, 1442, 543),shape=(5, 4)),\n",
       "  ExtractedTable(title=Example of Data Table 4, bbox=(235, 671, 1451, 971),shape=(5, 4))]}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time: 719 ms (started: 2023-06-06 01:09:50 +02:00)\n"
     ]
    }
   ],
   "source": [
    "pdf = PDF(src=\"data/tables.pdf\")\n",
    "\n",
    "# Extract tables\n",
    "extracted_tables = pdf.extract_tables(ocr=tesseract_ocr,\n",
    "                                      implicit_rows=False,\n",
    "                                      borderless_tables=False,\n",
    "                                      min_confidence=50)\n",
    "\n",
    "extracted_tables"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "3851b0ef",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-03-28T20:35:00.918518Z",
     "iopub.status.busy": "2023-03-28T20:35:00.918518Z",
     "iopub.status.idle": "2023-03-28T20:35:00.934543Z",
     "shell.execute_reply": "2023-03-28T20:35:00.934543Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<h3 style=\"text-align: center\">Page 1 - Extracted table n°1</h3>\n",
       "                   <p style=\"text-align: center\">\n",
       "                       <b>Title:</b> Example of Data Table 1<br>\n",
       "                       <b>Bounding box:</b> x1=235, y1=249, x2=1442, y2=543\n",
       "                   </p>\n",
       "                   <div align=\"center\"><table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>sample</td>\n",
       "      <td>blue LED value</td>\n",
       "      <td>green LED value</td>\n",
       "      <td>red LED value</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>clear water</td>\n",
       "      <td>97</td>\n",
       "      <td>19</td>\n",
       "      <td>79</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>blue water</td>\n",
       "      <td>73</td>\n",
       "      <td>11</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>green water</td>\n",
       "      <td>35</td>\n",
       "      <td>15</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>tea water</td>\n",
       "      <td>33</td>\n",
       "      <td>13</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table></div>\n",
       "                   <hr>\n",
       "                "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<h3 style=\"text-align: center\">Page 1 - Extracted table n°2</h3>\n",
       "                   <p style=\"text-align: center\">\n",
       "                       <b>Title:</b> Example of Data Table 2<br>\n",
       "                       <b>Bounding box:</b> x1=235, y1=671, x2=1451, y2=971\n",
       "                   </p>\n",
       "                   <div align=\"center\"><table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>sample</td>\n",
       "      <td>blue % transmitted</td>\n",
       "      <td>green % transmitted</td>\n",
       "      <td>red % transmitted</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>clear water</td>\n",
       "      <td>97/97 = 100%</td>\n",
       "      <td>19/19 = 100%</td>\n",
       "      <td>79/79 = 100%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>blue water</td>\n",
       "      <td>73/97 = 75%</td>\n",
       "      <td>11/19 = 58%</td>\n",
       "      <td>13/79 = 17%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>green water</td>\n",
       "      <td>35/97 = 36%</td>\n",
       "      <td>15/19 = 79%</td>\n",
       "      <td>14/79 = 18%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>tea water</td>\n",
       "      <td>33/97 = 34%</td>\n",
       "      <td>13/19 = 68%</td>\n",
       "      <td>70/79 = 91%</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table></div>\n",
       "                   <hr>\n",
       "                "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<h3 style=\"text-align: center\">Page 2 - Extracted table n°1</h3>\n",
       "                   <p style=\"text-align: center\">\n",
       "                       <b>Title:</b> Example of Data Table 3<br>\n",
       "                       <b>Bounding box:</b> x1=236, y1=249, x2=1442, y2=543\n",
       "                   </p>\n",
       "                   <div align=\"center\"><table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>sample</td>\n",
       "      <td>blue LED value</td>\n",
       "      <td>green LED value</td>\n",
       "      <td>red LED value</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>+ 1 tsp milk</td>\n",
       "      <td>13</td>\n",
       "      <td>14</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>+1tsp milk + blue</td>\n",
       "      <td>10</td>\n",
       "      <td>9</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>+1tsp milk +green</td>\n",
       "      <td>9</td>\n",
       "      <td>13</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>+1tsp milk + tea</td>\n",
       "      <td>7</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table></div>\n",
       "                   <hr>\n",
       "                "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<h3 style=\"text-align: center\">Page 2 - Extracted table n°2</h3>\n",
       "                   <p style=\"text-align: center\">\n",
       "                       <b>Title:</b> Example of Data Table 4<br>\n",
       "                       <b>Bounding box:</b> x1=235, y1=671, x2=1451, y2=971\n",
       "                   </p>\n",
       "                   <div align=\"center\"><table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Water sample</td>\n",
       "      <td>blue % transmitted</td>\n",
       "      <td>green % transmitted</td>\n",
       "      <td>red % transmitted</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>+ 1 tsp milk</td>\n",
       "      <td>13/13 = 100%</td>\n",
       "      <td>14/14 = 100%</td>\n",
       "      <td>12/12 = 100%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>+1tsp milk + blue</td>\n",
       "      <td>10/13 = 77%</td>\n",
       "      <td>9/14 = 64%</td>\n",
       "      <td>6/12 = 50%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>+1tsp milk +green</td>\n",
       "      <td>9/13 = 69%</td>\n",
       "      <td>13/14 = 93%</td>\n",
       "      <td>7/12 = 58%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>+1tsp milk + tea</td>\n",
       "      <td>7/13 = 54%</td>\n",
       "      <td>9/14 = 69%</td>\n",
       "      <td>9/12 = 75%</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table></div>\n",
       "                   <hr>\n",
       "                "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time: 15 ms (started: 2023-06-06 01:09:52 +02:00)\n"
     ]
    }
   ],
   "source": [
    "for page, tables in extracted_tables.items():\n",
    "    for idx, table in enumerate(tables):\n",
    "        display_html(table.html_repr(title=f\"Page {page + 1} - Extracted table n°{idx + 1}\"), raw=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7e94d997",
   "metadata": {},
   "source": [
    "### Export to xlsx\n",
    "\n",
    "All tables from a document can be exported in xslx format, with one table per worksheet.<br>\n",
    "Arguments are similar to the <code>extract_tables</code> method."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "e869f327",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-03-28T20:35:00.934543Z",
     "iopub.status.busy": "2023-03-28T20:35:00.934543Z",
     "iopub.status.idle": "2023-03-28T20:35:01.562787Z",
     "shell.execute_reply": "2023-03-28T20:35:01.562787Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time: 719 ms (started: 2023-06-06 01:09:55 +02:00)\n"
     ]
    }
   ],
   "source": [
    "pdf = PDF(src=\"data/tables.pdf\")\n",
    "\n",
    "# Export to file\n",
    "pdf.to_xlsx('data/tables.xlsx',\n",
    "            ocr=tesseract_ocr,\n",
    "            implicit_rows=False,\n",
    "            borderless_tables=False,\n",
    "            min_confidence=50)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "b177bacc",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-03-28T20:35:01.562787Z",
     "iopub.status.busy": "2023-03-28T20:35:01.562787Z",
     "iopub.status.idle": "2023-03-28T20:35:01.594066Z",
     "shell.execute_reply": "2023-03-28T20:35:01.594066Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Worksheet Page 1 - Table 1 : 5 rows, 4 columns\n",
      "Worksheet Page 1 - Table 2 : 5 rows, 4 columns\n",
      "Worksheet Page 2 - Table 1 : 5 rows, 4 columns\n",
      "Worksheet Page 2 - Table 2 : 5 rows, 4 columns\n",
      "time: 0 ns (started: 2023-06-06 01:09:57 +02:00)\n"
     ]
    }
   ],
   "source": [
    "for ws in load_workbook(\"data/tables.xlsx\"):\n",
    "    print(f\"Worksheet {ws.title} : {len(tuple(ws.rows))} rows, {len(tuple(ws.rows)[0])} columns\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
